<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/resources/include/header.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${applicationScope.__SYSTEM_ATTRIBUTE__.page_title.content }
	- 制作二维码</title>
<base target="_self" />
<%@ include file="/resources/include/plugin.jsp"%>
<%@ include file="/resources/include/extra.jsp"%>
<script type="text/javascript" src="${pageContext.request.contextPath }/resources/plugin/qrcode/jquery.qrcode.min.js"></script>

<script type="text/javascript">
$(function(){
	$("#code_2d").click(function(){
		$("#mycode").empty();
		var str = toUtf8($("#mytxt").val());
		var qrcode= $('#mycode').qrcode(str).hide(); 
		var canvas=qrcode.find('canvas').get(0);  
		$('#imgOne').attr('src',canvas.toDataURL('image/jpg'));
	});
})
function toUtf8(str) {   
    var out, i, len, c;   
    out = "";   
    len = str.length;   
    for(i = 0; i < len; i++) {   
    	c = str.charCodeAt(i);   
    	if ((c >= 0x0001) && (c <= 0x007F)) {   
        	out += str.charAt(i);   
    	} else if (c > 0x07FF) {   
        	out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));   
        	out += String.fromCharCode(0x80 | ((c >>  6) & 0x3F));   
        	out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));   
    	} else {   
        	out += String.fromCharCode(0xC0 | ((c >>  6) & 0x1F));   
        	out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));   
    	}   
    }   
    return out;   
}  
</script>
 
</head>
<body>
<jsp:include page="/core/base/layout/header" />
	<jsp:include page="/core/base/layout/left" />
	<jsp:include page="/core/base/layout/shortcut" />
	<div class="main-container">
		<ul class="breadcrumb">
			<li><a href="${pageContext.request.contextPath }/core/base/home"><i class="fa fa-home"></i>首页</a></li>
			<li><a href="javascript:void(0);"><i class="fa fa-paper-plane-o"></i>网站管理</a></li>
			<li class="active"><a href="javascript:void(0);"><i class="fa fa-file-text-o"></i>生成二维码</a></li>
		</ul>
		<div class="panel panel-default">
			<div class="panel-heading">
				<i class="fa fa-pencil"></i>制作
			</div>
			<div class="panel-body">
				<div class="form-group">
					<div class="col-lg-5 col-sm-5" style="margin-top: 10px; margin-bottom: 15px;">
						<br/>
						<label class="control-label text-left">输入内容点击生成按钮生成二维码</label><br/>
						<div>
							<textarea rows="3" style="width: 100%; margin-top: 5px;" id="mytxt" placeholder="请输入二维码包含的信息"></textarea>
						</div>
					
						<div>
							<input type="button" id="code_2d" style="width: 60%; margin-left: 20%; margin-bottom:10px;" class="btn btn-success" value="生成二维码" />
						</div>
					
						<div>
							<label class="control-label text-left">在二维码图片上点击鼠标右键->另存为可将二维码图片保存到本地</label>
						</div>
					</div>
						
					<div class="col-lg-5 col-sm-5">
						<div id="mycode"></div>
						<img id="imgOne" style="border:2px solid gray; width:200px; height:200px;">
					</div>
					<div class="col-lg-2 col-sm-2">
						
					</div>
				</div>
			</div>
		</div>
		<div class="clearfix"></div>
	</div>
</body>
</html>